Skip to content

feat(cold-store-reaper): class-A stagger planner and export-manifest builder (#13455 slice 1) - #13476

Merged
dezren39 merged 1 commit into
mainfrom
lane-oc-code-08/13455-class-a-slice1
Nov 24, 2026
Merged

dezren39 merged 1 commit into
mainfrom
lane-oc-code-08/13455-class-a-slice1

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Slice 1 of #13455 (backup-mesh class-A leg; design doc/2026-11-23T16-34-18Z_design_backup_mesh/note.md §§2-4, 9). No live export, no restic, no schedule — pure planner + manifest plus tests.

What: pkgs/cold-store-reaper/scripts/turso-mesh-class-a.py — deterministic weekly stagger for fleet-queue / fleet-platform / atlas (distinct weekdays, order-independent, stable slots) and the export-manifest contract restore verification checks against (db name, export timestamp, dump sha256, per-table row counts + order-independent content hashes, read-only SQLite). CLI: plan / manifest.

Tests: pkgs/cold-store-reaper/tests/test_turso_mesh_class_a.py — stdlib-seeded property cases (distinct + permutation-stable assignments; row-count fidelity vs SQL count(*); insertion-order hash invariance) and CLI examples for the three class-A DBs plus a fixture dump round trip.

Test command (oracle): python3 -m pytest pkgs/cold-store-reaper/tests/test_turso_mesh_class_a.py → 15 passed. Also green under python3 -m unittest discover -s pkgs/cold-store-reaper/tests (229 tests OK, 1 pre-existing skip).

Acceptance mapping (task 21387): planner distinct+deterministic ✓ (property), manifest fields ✓ (example + property), tests cover flooding-equivalent (permutation) + stalled-equivalent (rebuild round trip) ✓, this PR records command + oracle ✓.

Lane oc-code-08, task 21387.

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-23T16:50:39Z",
    "session_id": "ses_e5df6ba75e2ffeGl8Y8gExewgC",
    "lane": null,
    "host": "amd",
    "worktree": "/home/user/git/code-worktrees/oc-code-08-13455-slice1",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/user/git/code-worktrees/oc-code-08-13455-slice1",
      "repo": "developing-today/code",
      "branch": "lane-oc-code-08/13455-class-a-slice1",
      "sha": "6e370c961ddf61dd9ac0ada1b9b0cb1e2bbc6df3"
    },
    "auth_subject": "oc-code-05",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Prove it works
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…builder (#13455 slice 1)

First foundational slice of the backup-mesh class-A leg (design
doc/2026-11-23T16-34-18Z_design_backup_mesh/note.md §§2-4, 9):

- plan_class_a_week: deterministic weekly stagger for the class-A
  platform databases (fleet-queue, fleet-platform, atlas) — sorted
  names, stable sha256 start slot, linear probe over free weekdays;
  assignments are distinct, total, and order-independent.
- build_manifest: the export-manifest contract restore verification
  checks against — database name, export timestamp, dump sha256,
  per-table row counts and order-independent per-table content
  hashes over a read-only SQLite connection.
- CLI subcommands plan / manifest (no network, no credentials, no
  restic, no schedule — all excluded by the slice scope).
- Tests: stdlib-seeded property cases (injectivity, permutation
  stability, row-count fidelity vs SQL count(*), insertion-order
  hash invariance) plus CLI example tests for the three class-A
  databases and a fixture dump round trip.

Done check: python3 -m pytest pkgs/cold-store-reaper/tests/test_turso_mesh_class_a.py
(15 passed; also green under unittest discover, full cold-store-reaper
suite 229 tests OK).

Closes nothing by itself: slice 1 of #13455.

Lane oc-code-08, task 21387.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 27 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 067b0bd4-d6c6-43ff-82bc-6f5a87305dd8
Commits

Reviewing files that changed from the base of the PR and between f3e85a4 and 6e370c9.

Files selected for processing: 2

  • pkgs/cold-store-reaper/scripts/turso-mesh-class-a.py
  • pkgs/cold-store-reaper/tests/test_turso_mesh_class_a.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T16:54:06.126663Z 6e370c9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e370c961d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +200 to +202
manifest = sub.add_parser(
"manifest", help="build the export manifest for one snapshot"
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Disable abbreviated options on both subcommand parsers

When an operator supplies an undeclared flag prefix, argparse silently accepts it: plan --d typo-name exits successfully instead of reporting a usage error, and manifest accepts --o as the write-capable --out option. The manifest help declares --out, not --o. This violates the repository's strict argument contract, including rejection before file writes. Set allow_abbrev=False on both subcommand parsers; setting it only on the root parser does not propagate.

AGENTS.md reference: AGENTS.md:L44-L48

Useful? React with 👍 / 👎.

Comment on lines +176 to +178
with open(args.dump, "rb") as fh:
dump_bytes = fh.read()
manifest = build_manifest(args.db, args.sqlite, dump_bytes, args.exported_at)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound memory use while building large export manifests

For large class-A exports, this reads and retains the entire dump while _table_rows_and_hash additionally materializes and sorts each table's complete serialized contents. This is already relevant to canonical atlas: export-turso.sh documents its dump exceeding 10 GB and explicitly replaced whole-dump Python reads after OOM failures (lines 382–385). On memory-constrained backup workers, manifest generation can therefore fail even after the streaming export succeeds. Hash the dump incrementally and use a bounded-memory strategy for the order-independent table hashes rather than retaining the dump and whole-table copies together.

Useful? React with 👍 / 👎.

"dump_sha256": hashlib.sha256(dump_bytes).hexdigest(),
"tables": [],
}
conn = sqlite3.connect("file:%s?mode=ro" % sqlite_path, uri=True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Escape the SQLite pathname before constructing its URI

When the supplied SQLite pathname contains URI-reserved characters, interpolating it directly changes which file SQLite opens and can discard the read-only option. With a populated snapshot#1.sqlite, I verified that build_manifest instead creates an empty file named snapshot and successfully returns an empty tables list: the # makes the remaining pathname and ?mode=ro a URI fragment. This silently produces a manifest for the wrong database and violates the read-only contract. Convert the absolute pathname to a properly escaped file URI before appending ?mode=ro.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

audit:partial PR partially implemented; gap filed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant